#pragma once
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <utility>
#include <sstream>

#include <cv.h>
#include <cxcore.h>
#include <highgui.h>

#include "Tools.h"

using namespace std;
namespace Tools
{
	class WritingTrajectoire
	{
	public:
		WritingTrajectoire(vector<CvPoint> writing_trajectoire, CvPoint p0, CvPoint p1);
		~WritingTrajectoire(void);
		
		int g;
		float alpha;
		float w;

		float get_angle_deviation(const WritingTrajectoire &vj);
		static float get_curvature_variation(const WritingTrajectoire &spwt_i, const WritingTrajectoire &spwt_j);
		static float get_curvature(int k, const WritingTrajectoire &spwt_i, const WritingTrajectoire &spwt_j);

		static float get_direction_angle(CvPoint p0, CvPoint p1);
		static float get_angle_difference(float angle0, float angle1);
		static float alpha_thr0;
		static float alpha_thr1;

	private :
		void calculate();
		static CvPoint get_chain_point(int k,const WritingTrajectoire &spwt_i, const WritingTrajectoire &spwt_j);
		float mean_angle(int length);
		vector<CvPoint> spwt;
		CvPoint T0;
		CvPoint T1;

	};

}